package com.cloud.school.bus.teacherhelper.base.anim.swap3d;

import com.cloud.school.bus.teacherhelper.base.anim.Rotate3dAnimation;

import android.view.animation.AccelerateInterpolator;

public class RotationHelper {

	private Constants mConstants;

	public RotationHelper(Constants constants) {
		mConstants = constants;
	}

	public void applyRotation(int swapView, float start, float end) {
		System.out.println("applyRotation start......"); // Find the center of
															// the container
		final float centerX = mConstants.getViewGroup().getWidth() / 2.0f;
		final float centerY = mConstants.getViewGroup().getHeight() / 2.0f;
		// Create a new 3D rotation with the supplied parameter
		// The animation listener is used to trigger the next animation
		final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end,
				centerX, centerY, /*330.0f*/0, true);
		rotation.setDuration(Constants.duration);
		rotation.setFillAfter(true);
		rotation.setInterpolator(new AccelerateInterpolator());
		rotation.setAnimationListener(new DisplayNextView(mConstants, swapView));
		mConstants.getViewGroup().startAnimation(rotation);
		System.out.println("applyRotation end .....");
	}

}
